The present invention relates to parity generation, in particular parity calculations in conjunction with the write cache for a RAID system.
In a RAID (redundant array of independent disks) system, a number of small disk drives are used to store data with the data being spread across a number of the disk drives. An example of such a system is set forth in U.S. Pat. No. 5,140,592. A number of schemes exist for correcting errors and detecting corruption of the data. When the data is received from a host computer by a RAID controller, it typically arrives in 8-bit byte form, with a ninth, parity bit for each byte. The controller writes the data across a number of disks, putting different blocks of data in different disks. Data is usually written a sector at a time, such that blocks of the data for that sector are written across the sectors on four disk drives, for instance.
Typically, the RAID controller as it writes the data will generate a check code. One example, is CRC (cyclic redundancy check). This is basically an exclusive OR (XOR) of each bit position in successive bytes throughout a sector. Another example is linear parity, which is an exclusive OR (XOR) function of successive words of any convenient length. Finally, there is Reed Solomon codes, which use polynomials to produce P and Q terms, as discussed in more detail in U.S. Pat. No. 5,140,592.
In addition to these check codes, the RAID controller also provides a parity calculation. The parity is the exclusive OR of the data blocks in each disk drive, with the exclusive OR being a parity block which is stored on a separate, parity disk. Thus, for example, if four data disks are used, there is a fifth disk added for parity (RAID 3), or the parity sectors may be distributed among all the drives (RAID 5). Typically, the parity calculation is done not only on the data itself, but on the check codes which are stored with the data on each disk drive. In addition, each disk drive sector may have a header field, which uniquely identifies the location of that data sector in the disk drive RAID memory. The header thus self-describes its location, allowing a determination of where it belongs without the disk controller keeping track of it. Typically, the parity drive will have a header field which is the exclusive OR of the headers of the data sectors.
When a write operation is done to data in the RAID array, it may be a write to just a portion of the data which is stored on one of the disk drives. Typically, an entire sector is written even if only a portion of the data on that sector is changed. In order to accomplish this write, it is not necessary to read all of the disk drives in the four plus one grouping. Rather, the data sector to be written can be read, along with the parity sector. By exclusive ORing the data sector with the parity sector, a new parity is generated which is equivalent to the parity for the remaining disk drives which have not been read. Then, the new data can be exclusive Ored with its new parity to generate a parity for all four disk drives with the new data. Then, the new data and the new parity can be written to the disk drives.
Before performing this operation, typically the check code is recalculated after the data is read by the controller to determine that the data has been accurately read. This requires regenerating the check code by looping through all the data to perform the function necessary to generate the check code. Once this is accomplished, and the data is verified as being valid, the process of calculating a new parity can be done.
Some disk controllers use a write cache so that multiple writes can be done without accessing the disk drives themselves. The same process is followed, except that the data sector and parity sector are stored in the write cache for an extended period of time, allowing multiple writes to be done before the data is written back to the disk drive. Storing the data in the write cache for an extended period of time increases the risk that the data could be corrupted due to some other operation which writes over the data, due to a power failure, or otherwise. One approach to the risk of a write cache is to store the parity data in a separate memory. Such a system is shown in U.S. Pat. No. 5,239,640 (parity is called "check-sum" in this patent).
Since a write cache is typically more volatile than a disk drive, the parity information is at risk of being corrupted in the write cache. The data is protected by a check code, but the parity information contains parity of the data check codes and is not itself separately protected.